package com.ihr360.sharedservice.api;

import com.ihr360.sharedservice.api.fallback.DataCacheServiceFallBack;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Created by Eric on 2018/4/10/010.
 */
@FeignClient(name = "ihr360-shared-service-provider",fallback = DataCacheServiceFallBack.class)
public interface DataCacheService {

    @RequestMapping(value = "/common/cache/put", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    void put(@RequestParam(value = "key") String key,@RequestParam(value = "value")  String value);

    @RequestMapping(value = "/common/cache/remove", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    void remove(@RequestParam(value = "key") String key);

    @RequestMapping(value = "/common/cache/removeAll", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    void removeAll(@RequestParam(value = "keys") Set<String> keys);

    @RequestMapping(value = "/common/cache/putAll", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    void putAll(@RequestParam(value = "map") Map<String,String> map);

    @RequestMapping(value = "/common/cache/getAll", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    List<String> getAll(@RequestParam(value = "keys") List<String> keys);

    @RequestMapping(value = "/common/cache/get", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    String get(@RequestParam(value = "key") String key);
}
